package com.lizhi.yun.core.menu.controller;/**
 * @program: spring-boot
 * @name UppMenuController
 * @description:
 * @author: lizhi
 * @create: 2020-04-11 19:02
 */

import com.lizhi.common.yun.entity.ListResponseResult;
import com.lizhi.yun.db.pojo.UppMenuPOJO;
import com.lizhi.yun.core.menu.handler.UppMenuHandle;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 *@program: spring-boot
 *@name UppMenuController
 *@description:
 *@author: lizhi
 *@create: 2020-04-11 19:02
 */
@Slf4j
@RestController
@RequestMapping(value = "/api/upp/menu")
public class UppMenuController {

    @Resource
    private UppMenuHandle uppMenuHandle;

    @PostMapping(path = "/doMain")
    public ListResponseResult doMain(@RequestParam Map<String, Object> map) {
        return uppMenuHandle.doMain(map);
    }

    @PostMapping(path = "/doAdd")
    public ListResponseResult doAdd(@RequestBody UppMenuPOJO uppMenuPOJO){
        return uppMenuHandle.insert(uppMenuPOJO);
    }

    @PostMapping(path = "/doUpdate")
    public ListResponseResult doUpdate(@RequestBody UppMenuPOJO uppMenuPOJO){
        return uppMenuHandle.update(uppMenuPOJO);
    }

    @PostMapping(path = "/isNotexists")
    public ListResponseResult isNotexistsUppMenu(String menuId) {
        return uppMenuHandle.isNotexists(menuId);
    }

    @DeleteMapping(path = "/doDelete")
    public ListResponseResult doDelete(String menuId) {
        return uppMenuHandle.delete(menuId);
    }

    @PostMapping(path = "/selectById")
    public ListResponseResult findUppMenuById(String menuId){
        return uppMenuHandle.findById(menuId);
    }

    @PostMapping(path = "/isExistsByParentMenuId")
    public ListResponseResult isExistsByParentMenuId(String menuId) {
        return uppMenuHandle.isExistsByParentMenuId(menuId);
    }
}
